<template>
  <div class="wrapper1">
    <template v-for="item in list">
      <produce-item :data="item" :key="item.id"/>
    </template>
  </div>
</template>

<script>
import ProduceItem from '@/views/part/shopDetail/part/goodInfo/part/tableDescrition/ProduceItem'
import { queryGoodProduceByGoodId } from '@/api/ApiGoodProduce'
import { ResultCode } from '@/constants/constants'
export default {
  name: 'TabDescription',
  components: { ProduceItem },
  props: {
    data: {
      required: true,
      type: Object
    }
  },
  data () {
    return {
      queryLoading: false,
      list: []
    }
  },
  methods: {
    freshData () {
      if (this.queryLoading || !this.data || !this.data.id) {
        return
      }
      this.queryLoading = true
      queryGoodProduceByGoodId(this.data.id, data => {
        if (data && data.code === ResultCode.OK) {
          this.list = data.object
        }
      }, () => {
        this.queryLoading = false
      })
    }
  },
  mounted () {
    this.freshData()
  },
  watch: {
    data () {
      this.freshData()
    }
  }
}
</script>

<style scoped lang="scss">
.wrapper1{
  margin: 30px 160px;
}
</style>
